<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		
		<title>提交按钮动画</title>
		<style type="text/css">
			@import 'https://fonts.googleapis.com/css?family=Roboto:300,500,700';
body {
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
      -ms-flex-align: center;
          align-items: center;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
      -ms-flex-pack: center;
          justify-content: center;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -webkit-flex-direction: column;
      -ms-flex-direction: column;
          flex-direction: column;
  height: 100vh;
  widht: 100vw;
  overflow: hidden;
  background: #fafafa;
  font-family: "Roboto", sans-serif;
  font-weight: 400;
  font-size: 14px;
  font-smooth: auto;
  -webkit-font-smoothing: antialiased;
}

header {
  position: absolute;
  top: 30px;
  width: calc(30px + 15em);
  left: calc(50% - 15px - 7.5em);
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  -webkit-flex-flow: row nowrap;
      -ms-flex-flow: row nowrap;
          flex-flow: row nowrap;
  -webkit-box-align: center;
  -webkit-align-items: center;
      -ms-flex-align: center;
          align-items: center;
  -webkit-justify-content: space-around;
      -ms-flex-pack: distribute;
          justify-content: space-around;
  margin-bottom: 1em;
  font-size: 0.8em;
}
header .header--text {
  letter-spacing: 1px;
}
header .header--text span {
  color: #777;
  font-weight: 300;
  margin-bottom: 0;
}
header .header--text a {
  display: inline-block;
  margin-top: 0;
  text-decoration: none;
  font-weight: 700;
  color: #ea4c89;
  -webkit-transition: color 300ms ease;
  transition: color 300ms ease;
}
header .header--text a:hover {
  color: #ef7aa7;
}
header #logo-dribbble {
  width: 2em;
  height: auto;
  fill: #ea4c89;
  -webkit-transition: fill 300ms ease;
  transition: fill 300ms ease;
}
header #logo-dribbble:hover {
  fill: #ef7aa7;
}

button.btnSubmit {
  outline: none;
  border: none;
  cursor: default;
  -webkit-transition: box-shadow 300ms ease;
  transition: box-shadow 300ms ease;
  letter-spacing: 2px;
  box-shadow: 0px 0px 52px 10px rgba(255, 255, 255, 0);
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
  position: relative;
  box-sizing: border-box;
  width: 175px;
  height: 50px;
  border-radius: 35px;
  border: 2px solid;
  border-color: #1ECD97;
  background: none;
  color: #1ECD97;
  -webkit-transition: all 300ms ease-out;
  transition: all 300ms ease-out;
}
button.btnSubmit:hover {
  cursor: pointer;
  font-size: 1.05em;
  border-color: transparent;
  background: #1ECD97;
  color: #fafafa;
  box-shadow: 0px 0px 52px 10px rgba(255, 255, 255, 0.7);
}
button.btnSubmit.clicked {
  pointer-events: none;
  -webkit-animation: anim1 200ms cubic-bezier(0.2, 0, 0.8, 1), anim2 300ms cubic-bezier(0.6, 0, 0.7, 1) 300ms 1 forwards;
          animation: anim1 200ms cubic-bezier(0.2, 0, 0.8, 1), anim2 300ms cubic-bezier(0.6, 0, 0.7, 1) 300ms 1 forwards;
}
button.btnSubmit.clicked.done {
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
      -ms-flex-pack: center;
          justify-content: center;
  -webkit-box-align: center;
  -webkit-align-items: center;
      -ms-flex-align: center;
          align-items: center;
  width: 50px;
  background: #1ECD97;
  background: -webkit-linear-gradient(0, #1ECD97, #25dfa6);
  background: linear-gradient(0, #1ECD97, #25dfa6);
  border: 2px solid transparent;
  color: rgba(30, 205, 151, 0);
  -webkit-transition: all 1000ms ease;
  transition: all 1000ms ease;
  -webkit-animation: anim4 300ms cubic-bezier(0.2, 0, 0.4, 1) forwards;
          animation: anim4 300ms cubic-bezier(0.2, 0, 0.4, 1) forwards;
}

svg.svg--template {
  display: none;
}

svg.loader {
  position: absolute;
  width: 50px;
  height: 50px;
  overflow: visible;
}

svg.loader {
  position: absolute;
  left: -2px;
  top: -2px;
  width: 50px;
  height: 50px;
}
svg.checkmark {
  height: 1.2em;
  width: 100%;
}
svg .circle1 {
  stroke: #1ECD97;
  stroke-width: 3px;
  r: 23.5px;
  cx: 25px;
  cy: 25px;
  width: 100%;
  height: 100%;
  stroke-dasharray: 157px;
  -webkit-transform: rotate(-90deg);
          transform: rotate(-90deg);
  -webkit-transform-origin: 50% 50%;
          transform-origin: 50% 50%;
  -webkit-animation: anim3 2.5s cubic-bezier(0.6, 0, 0, 1);
          animation: anim3 2.5s cubic-bezier(0.6, 0, 0, 1);
}
svg .checkmark1 {
  fill: #fafafa;
}
svg .checkmark1 .line1 {
  -webkit-transform-origin: 100% 100%;
          transform-origin: 100% 100%;
}
svg .checkmark1 .line2 {
  -webkit-transform-origin: 0% 100%;
          transform-origin: 0% 100%;
}
svg .checkmark1 .line1, svg .checkmark1 .line2 {
  -webkit-animation: growAndRotate 500ms cubic-bezier(0.4, 0, 0, 1);
          animation: growAndRotate 500ms cubic-bezier(0.4, 0, 0, 1);
}

@-webkit-keyframes anim1 {
  0% {
    font-size: 1.05em;
  }
  50% {
    font-size: 0.9em;
  }
  100% {
    font-size: 1.05emj;
  }
}

@keyframes anim1 {
  0% {
    font-size: 1.05em;
  }
  50% {
    font-size: 0.9em;
  }
  100% {
    font-size: 1.05emj;
  }
}
@-webkit-keyframes anim2 {
  40% {
    border-radius: 35px;
  }
  20%, 100% {
    color: rgba(30, 205, 151, 0);
  }
  100% {
    background: none;
    border-width: 2px;
    border-color: #C5C5C5;
    border-radius: 50%;
    padding: 0;
    width: 50px;
  }
}
@keyframes anim2 {
  40% {
    border-radius: 35px;
  }
  20%, 100% {
    color: rgba(30, 205, 151, 0);
  }
  100% {
    background: none;
    border-width: 2px;
    border-color: #C5C5C5;
    border-radius: 50%;
    padding: 0;
    width: 50px;
  }
}
@-webkit-keyframes anim3 {
  0% {
    stroke-dashoffset: 157px;
  }
  100% {
    stroke-dashoffset: 0;
  }
}
@keyframes anim3 {
  0% {
    stroke-dashoffset: 157px;
  }
  100% {
    stroke-dashoffset: 0;
  }
}
@-webkit-keyframes anim4 {
  0% {
    border-radius: 50%;
    width: 50px;
  }
  40% {
    border-radius: 35px;
  }
  100% {
    width: 175px;
  }
}
@keyframes anim4 {
  0% {
    border-radius: 50%;
    width: 50px;
  }
  40% {
    border-radius: 35px;
  }
  100% {
    width: 175px;
  }
}
@-webkit-keyframes growAndRotate {
  0% {
    opacity: 0;
    -webkit-transform: scale(0.4) rotate(-5deg);
            transform: scale(0.4) rotate(-5deg);
  }
  30%, 100% {
    opacity: 1;
  }
  100% {
    -webkit-transform: scale(1) rotate(0);
            transform: scale(1) rotate(0);
  }
}
@keyframes growAndRotate {
  0% {
    opacity: 0;
    -webkit-transform: scale(0.4) rotate(-5deg);
            transform: scale(0.4) rotate(-5deg);
  }
  30%, 100% {
    opacity: 1;
  }
  100% {
    -webkit-transform: scale(1) rotate(0);
            transform: scale(1) rotate(0);
  }
}
#browserAlert {
  z-index: 10;
  display: none;
  left: 0;
  top: 0;
  position: absolute;
  width: 100vw;
  height: 100vh;
  background: rgba(255, 255, 255, 0.8);
  pointer-events: none;
  font-size: 2em;
}
#browserAlert.active {
  display: block;
}
#browserAlert.active span {
  position: absolute;
  left: 50%;
  top: 50%;
  -webkit-transform: translate(-50%, -50%);
          transform: translate(-50%, -50%);
}

.side-note {
  padding-top: 1em;
  position: absolute;
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: start;
  -webkit-justify-content: flex-start;
      -ms-flex-pack: start;
          justify-content: flex-start;
  -webkit-box-align: center;
  -webkit-align-items: center;
      -ms-flex-align: center;
          align-items: center;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -webkit-flex-direction: column;
      -ms-flex-direction: column;
          flex-direction: column;
  height: 10em;
  min-width: 20em;
  border-top: 2px solid #aeaeae;
  background: white;
  z-index: 10;
  -webkit-transform: rotate(-45deg);
          transform: rotate(-45deg);
  -webkit-transform-origin: 100% 100%;
          transform-origin: 100% 100%;
  right: -8.5em;
  bottom: 5em;
  font-weight: 300;
  font-size: 0.7em;
  color: #aeaeae;
}
.side-note a {
  color: #7b7b7b;
  margin-top: 0.3em;
  cursor: default;
  text-decoration: underline;
  color: inherit;
  font-weight: 500;
  -webkit-transition: color 300ms ease;
  transition: color 300ms ease;
}
.side-note a:hover {
  color: #616161;
}

		</style>
	</head>
	<body>
		
		<!-- SVG templates -->
<!-- Would have used <use> but it's tricky to style and trasition Shadow DOM elements -->

<svg class="svg--template loader">
  <circle class="circle1" stroke="none" stroke-width="4" fill="none" r="25" cx="25" cy="25"/>
</svg>
<svg class="svg--template checkmark" viewBox="0 0 50 50">
  <g class="checkmark1">
    <path class="line1" d="M20.8,36l-4,4c-0.7,0.7-1.7,0.7-2.4,0L0.8,26.4c-0.7-0.7-0.7-1.7,0-2.4l4-4c0.7-0.7,1.7-0.7,2.4,0l13.6,13.6
    C21.5,34.3,21.5,35.4,20.8,36z"/>
  <path class="line2" d="M14.5,39.9l-4-4c-0.7-0.7-0.7-1.7,0-2.4L43.4,0.6c0.7-0.7,1.7-0.7,2.4,0l4,4c0.7,0.7,0.7,1.7,0,2.4L16.9,39.9
    C16.3,40.6,15.2,40.6,14.5,39.9z"/>
  </g>
</svg>

<svg class="svg--template" viewBox="0 0 304 305" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg">
  <symbol id="shadow--logo-dribbble">
		<path id="SVGID_1_" d="M152,298.2C73,298.2,8.7,234,8.7,155.1C8.7,76.2,73,12,152,12c79,0,143.3,64.2,143.3,143.1
			C295.3,234,231,298.2,152,298.2L152,298.2z M272.8,174.7c-4.2-1.3-37.9-11.4-76.2-5.2c16,43.9,22.5,79.7,23.8,87.1
			C247.8,238.1,267.4,208.7,272.8,174.7L272.8,174.7z M199.8,267.8c-1.8-10.7-8.9-48.1-26.1-92.7c-0.3,0.1-0.5,0.2-0.8,0.3
			c-69,24-93.8,71.8-96,76.3c20.8,16.2,46.8,25.8,75.1,25.8C168.9,277.5,185.1,274.1,199.8,267.8L199.8,267.8z M61.1,237
			c2.8-4.7,36.4-60.3,99.5-80.7c1.6-0.5,3.2-1,4.8-1.5c-3.1-6.9-6.4-13.9-9.9-20.7C94.3,152.4,35,151.7,29.7,151.6
			c0,1.2-0.1,2.5-0.1,3.7C29.6,186.7,41.5,215.4,61.1,237L61.1,237z M32.2,130.3c5.5,0.1,55.9,0.3,113.1-14.9
			c-20.3-36-42.1-66.3-45.4-70.7C65.7,60.8,40.1,92.3,32.2,130.3L32.2,130.3z M123.3,36.5c3.4,4.5,25.6,34.8,45.7,71.5
			c43.5-16.3,61.9-41,64.1-44.1c-21.6-19.1-50-30.8-81.1-30.8C142.1,33.1,132.5,34.3,123.3,36.5L123.3,36.5z M246.7,78
			c-2.6,3.5-23.1,29.7-68.3,48.2c2.8,5.8,5.6,11.7,8.1,17.7c0.9,2.1,1.8,4.2,2.6,6.3c40.7-5.1,81.2,3.1,85.2,3.9
			C274.1,125.3,263.8,98.8,246.7,78L246.7,78z"/>
  </symbol>
</svg>



<div id="browserAlert" style="display: none"><span></span></div>

<!-- --------------------------------------------------------------------------- -->

<header>
  <svg id="logo-dribbble" viewBox="0 0 304 305" width="150" height="150">
   <use xlink:href="#shadow--logo-dribbble"></use>
</svg>
  <div class="header--text"><span>Inspired by: </span><a href="https://dribbble.com/shots/1426764-Submit-Button" target="_blank">Colin Garven</a></div>
</header>

<main>
  <!-- button -->
  <button class="btnSubmit">Submit</button>
</main>
<script src="../js/jquery-1.11.2.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
	/*
TESTED SUCCESFFULY ON: Chrome 52 / Firefox 48
DON'T VIEW ON: Edge
*/

$(function() {

  // check if browser is not supported
  var $browserAlert = $('#browserAlert');
  $browserAlert.hide();

  $.ajax({
    url: 'https://cdn.rawgit.com/arasatasaygin/is.js/master/is.min.js',
    dataType: "script",
    success: function() {

      if (is.edge() || is.ie()) {
        $browserAlert.find('span').text('View on Chrome/Firefox.');
        $browserAlert.show();
        $browserAlert.addClass('active');
      }

    }
  });

  var $btn = $("button.btnSubmit");
  var $loaderTemplate = $("svg.loader");
  var $checkmarkTemplate = $("svg.checkmark");

  $btn.on('click', function() {
    if ($(this).hasClass('clicked')) return;
    $(this).addClass('clicked');
    var self = $(this);
    var timeout1 = 600,
      timeout2 = 2500,
      timeout3 = 3000;
    setTimeout(function() {

      self.append($loaderTemplate.clone());
      self.find('svg').removeClass('svg--template');
      self.find('svg').css('display', 'initial');
    }, timeout1);
    setTimeout(function() {
      self.text('');
      self.find('svg').remove();
      self.append($checkmarkTemplate.clone());
      self.find('svg').css('display', 'initial');
      self.find('svg').removeClass('svg--template');
      self.addClass('done');
    }, timeout1 + timeout2);
    setTimeout(function() {
      self.find('svg').remove();
      self.text('Submit');
      self.removeClass('clicked');
      self.removeClass('done');
    }, timeout1 + timeout2 + timeout3);
  });

});
</script>
	</body>
</html>
